#ifndef RDPSESSION_H
#define RDPSESSION_H

#include <filesystem>
#include <thread>

#include <winpr/crt.h>
#include <winpr/ssl.h>
#include <winpr/synch.h>
#include <winpr/file.h>
#include <winpr/string.h>
#include <winpr/path.h>
#include <winpr/winsock.h>

#include <freerdp/channels/wtsvc.h>
#include <freerdp/channels/channels.h>

#include <freerdp/constants.h>
#include <freerdp/server/rdpsnd.h>

extern "C" {
    #include "sfreerdp.h"
    #include "sf_encomsp.h"
}
#include <QObject>
#include <QSize>
#include <QTimer>
#include <QMutex>
#include <QWaitCondition>

class rdpsession:public QObject
{
    Q_OBJECT
public:
    rdpsession(QObject *parent = nullptr);
    ~rdpsession();
    void setclientPtr(LPVOID arg);
    void settlsCertificate(const std::filesystem::path &newTlsCertificate);    
    void settlsCertificateKey(const std::filesystem::path &newTlsCertificateKey);
    int initSettings();
    void start();
private slots:
    void sendFrame();

signals:    
    void frameReceived();

private:
    /* data */
    freerdp_peer* clientPtr = nullptr;
    std::thread clientThread;
    DWORD WINAPI run();
    std::thread updateFrameThread;
    void updateFrame();


    std::filesystem::path m_tlsCertificate;
    std::filesystem::path m_tlsCertificateKey;

    std::atomic<bool> ready=false;
    std::atomic<bool> diconnnect=false;

};




#endif